// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

// 云函数入口函数
exports.main = async (event, context) => {
  const db = cloud.database()
  try {
    const result = await cloud.openapi.subscribeMessage.send({
      touser: event.openid,
      page: 'pages/index/index',
      data: {
        thing7: {
          value: event.place1
        },
        thing2: {
          value: event.place2
        },
        time6: {
          value: event.ordertime
        },
        thing4: {
          value: "查看报名详情"
        }
      },
      templateId: 'pPR8B6TAfsR3hGewWrexY8wVPZwzykuw5C671OYX0Ks'
    })
    console.log(result)
    return result
  } catch (err) {
    console.log(err)
    return err
  }
}